<script setup>
import { setToken, clearStore } from '@/utils/webStorage'
import { post } from '@/axios/utils/request'
import { ElLoading,ElMessage } from 'element-plus'
import { useRouter,useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()

// const fullscreenLoading = ref(true)

const loading = ElLoading.service({
    lock: true,
    text: '正在校验身份...',
    fullscreen: true,
  })
if(route.query.token) {
  // router.push('/detectionPage?token='+route.query.token)

  post('/user/tokenLogin', {
    token: route.query.token,
  }).then((res) => {
    console.log(res);

    setToken(res.token)
    localStorage.setItem('ssotoken', res.ssotoken)
    loading.close()
    setTimeout(() => {
      router.replace('/home')
    }, 1000);

  }).catch((err) => {
    console.log(err);
    clearStore()
    loading.close()
    // ElMessage.error('校验失败，请重新登录')
     setTimeout(() => {
      router.replace('/home')
    }, 1000);
  })
}
</script>

<template>
  <!-- <div class="p-4" v-loading.fullscreen.lock="fullscreenLoading">

  </div> -->
</template>
